package com.juzipi.demo.config;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.juzipi.demo.pojo.Cat;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * @Author juzipi
 * @Date 2021/5/2 11:11
 * @Info excel监听器
 */
@Configuration
public class ExcelListener extends AnalysisEventListener<Cat> {


    //一行一行的读取内容,从第二行开始读取，第一行为表头
    @Override
    public void invoke(Cat data, AnalysisContext context) {
        System.out.println(data.getName());
    }


    //读取表头内容
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头信息："+headMap);
    }

    //读取之后执行
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        System.out.println(context);
    }
}
